from concurrent.futures import ThreadPoolExecutor
import requests
import uuid
import json
import sys
import os

sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))

from model.car_number import CarNumber

from proxy.tunnel_proxy_service_qg import TunnelProxyService_QG
from common.logger import logger
from spider.yun_park import YunParkSpider
from account.yun_account_service import YunAccountService

import spider_config

# 生成guid

import threading

write_lock = threading.RLock()


def test():
    try:
        account = YunAccountService(600)
        account.active()
        spider = YunParkSpider()
        spider.setProxy(None)
        spider.setAccount(account.take())
        logger.success(spider.query(CarNumber("渝DLX213")))
        print("success")
    except Exception as e:
        logger.exception(e)


if __name__ == "__main__":
    thread_count = 1

    thread_pool = ThreadPoolExecutor(max_workers=thread_count)

    futures = []
    for i in range(thread_count):
        futures.append(thread_pool.submit(test))

    thread_pool.shutdown(wait=True)
